package server;

import java.util.HashMap;
import com.google.protobuf.GeneratedMessage.Builder;

import command.ExceptionResponseFactory;
import command.GetUserTimelineCommandFactory;
import command.ICommandFactory;

public class CommandFactories {
	public static enum CmdType {
		getusertimeline, getuserhometimeline,nullresponse,exceptionresponse
	};

	public static CmdType[] cmdTypes = CmdType.values();
	
	private static HashMap<CmdType, ICommandFactory> factoryMap = new HashMap<CmdType, ICommandFactory>();

	public static void init() {
		factoryMap.put(CmdType.getusertimeline,
				new GetUserTimelineCommandFactory());
		factoryMap.put(CmdType.exceptionresponse, new ExceptionResponseFactory());
	}

	public static ICommandFactory getCommand(CmdType type) {
		return factoryMap.get(type);
	}
	
	public static CmdType getCommandTypeFromInt(int cmdIndex) {
		return cmdTypes[cmdIndex];
	}
}
